﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using WPF_DbCenter.CommonMethod;
using System.ServiceProcess;
using WPF_DbCenter.AdditionUI;
using WPF_DbCenter.SqlCE.AdditionUI;

namespace WPF_DbCenter.UI
{
    /// <summary>
    /// Interaction logic for DataExchange.xaml
    /// </summary>
    public partial class DataExchange : BaseUI.BaseFadeDialog
    {
        public DataExchange()
        {
            InitializeComponent();
            WindowStartupLocation = WindowStartupLocation.CenterScreen;
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            Access2SDF sf = new Access2SDF();
            sf.Owner = this;
            sf.ShowDialog();
        }

        /// <summary>
        /// Sql Server
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            SqlServer2Sdf ssf = new SqlServer2Sdf();
            ssf.Owner = this;
            ssf.ShowDialog();
        }

        /// <summary>
        /// Mysql 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button3_Click(object sender, RoutedEventArgs e)
        {
            CommonUtil.ResultArgs args=CommonUtil.DetectMySqlService();
            if (!args.HasThisService)
            {
                MessageBox.Show("You do not has mysql database installed ,or not running the service");
                return;
            }
            if (args.status != ServiceControllerStatus.Running)
            {
                if (!CommonUtil.StartServices(CommonUtil.MySqlServiceName))
                {
                    MessageBox.Show("Your mysql database can't run .Process will cancel");
                    return;
                }
            }

            AdditionUI.MySql2SDF msdf = new WPF_DbCenter.AdditionUI.MySql2SDF();
            msdf.Owner = this;
            msdf.ShowDialog();
        }

        private void butOracle_Click(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("Not Completed");
        }

        private void button5_Click(object sender, RoutedEventArgs e)
        {
            Excel2SDF sf = new Excel2SDF();
            sf.Owner = this;
            sf.ShowDialog();
        }

        private void button6_Click(object sender, RoutedEventArgs e)
        {
            Csv2Sdf sf = new Csv2Sdf();
            sf.Owner = this;
            sf.ShowDialog();
        }
    }
}
